package dto

import (
	"time"
	"vrcm/src/vrcm/app/admin/models/live"
	"vrcm/src/vrcm/common/dto"
	common "vrcm/src/vrcm/common/models"
)

type RecordListViewGetPageReq struct {
	dto.Pagination `search:"-"`
	FileName       string `json:"file_name"  search:"type:contains;column:file_name;table:record_list_view"`
	BasicId        int    `json:"basic_id"  search:"type:exact;column:basic_id;table:record_list_view" validate:"required"`
	TenantId       string `json:"tenant_id"  search:"type:exact;column:tenant_id;table:record_list_view" validate:"required"`
	//Sort           string `json:"sort"  search:"type:order;column:sort;table:record_list_view"`
	//RecordListViewOrder
}
type RecordListViewOrder struct {
	Id         string `form:"idOrder"  search:"type:order;column:id;table:record_list_view"`
	TenantId   string `form:"tenant_idOrder"  search:"type:order;column:tenant_id;table:record_list_view"`
	BasicId    string `form:"basic_idOrder"  search:"type:order;column:basic_id;table:record_list_view"`
	LiveId     string `form:"live_idOrder"  search:"type:order;column:live_id;table:record_list_view"`
	RecordId   string `form:"record_idOrder"  search:"type:order;column:record_id;table:record_list_view"`
	TaskId     string `form:"task_idOrder"  search:"type:order;column:task_id;table:record_list_view"`
	RecordUrl  string `form:"record_urlOrder"  search:"type:order;column:record_url;table:record_list_view"`
	FileName   string `form:"file_nameOrder"  search:"type:order;column:file_name;table:record_list_view"`
	FileType   string `form:"file_typeOrder"  search:"type:order;column:file_type;table:record_list_view"`
	Duration   string `form:"durationOrder"  search:"type:order;column:duration;table:record_list_view"`
	FileTime   string `form:"file_timeOrder"  search:"type:order;column:file_time;table:record_list_view"`
	CreateBy   string `form:"createByOrder"  search:"type:order;column:create_by;table:record_list_view"`
	UpdateBy   string `form:"updateByOrder"  search:"type:order;column:update_by;table:record_list_view"`
	CreateTime string `form:"create_timeOrder"  search:"type:order;column:create_time;table:record_list_view"`
	UpdateTime string `form:"update_timeOrder"  search:"type:order;column:update_time;table:record_list_view"`
}

func (m *RecordListViewGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type RecordListGetPageReq struct {
	dto.Pagination `search:"-"`
	TenantId       string `json:"tenant_id"  search:"type:exact;column:tenant_id;table:record_list" validate:"required"`
	LiveId         string `json:"live_id"  search:"type:exact;column:live_id;table:record_list"`
	StartTime      int    `json:"start_time"  search:"-"`
	EndTime        int    `json:"end_time"  search:"-"`
	BasicId        int    `json:"basic_id"  search:"-"`
}

func (m *RecordListGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type RecordListViewMultiInsertReq struct {
	RecordViews []RecordListViewInsertReq `json:"record_views" comment:"录制文件记录" validate:"required"`
	Count       int64                     `json:"count" comment:"数据条目数"`
}

type RecordListViewInsertReq struct {
	Id           int    `uri:"id" comment:""` //
	TenantId     string `json:"tenant_id" comment:"租户" validate:"required"`
	BasicId      int    `json:"basic_id" comment:"直播间基本信息id" validate:"required"`
	LiveId       string `json:"live_id" comment:"直播id" validate:"required"`
	RecordId     string `json:"record_id" comment:"录制记录id" validate:"required"`
	TaskId       string `json:"task_id" comment:"录制任务id" validate:"required"`
	RecordUrl    string `json:"record_url" comment:"录制视频地址" validate:"required"`
	FileName     string `json:"file_name" comment:"文件名" validate:"required"`
	FileType     string `json:"file_type" comment:"文件类型"  validate:"required"`
	Duration     int64  `json:"duration" comment:"持续时间" validate:"gt=0"`
	FileTime     int64  `json:"file_time" comment:"文件生成时间"  validate:"gt=0"`
	OperatorType int    `json:"operator" comment:"1录制 2上传"`
	CreateTime   int64  `json:"create_time" comment:"创建时间"`
	UpdateTime   int64  `json:"update_time" comment:"修改时间"`
	common.ControlBy
}

func (c *RecordListViewMultiInsertReq) Generate(models *[]live.RecordListView) {

	index := c.Count
	for k, model := range c.RecordViews {
		recordView := live.RecordListView{}
		now := time.Now().Unix()
		recordView.TenantId = model.TenantId
		recordView.BasicId = model.BasicId
		recordView.LiveId = model.LiveId
		recordView.RecordId = model.RecordId
		recordView.TaskId = model.TaskId
		recordView.RecordUrl = model.RecordUrl
		recordView.FileName = model.FileName
		recordView.FileType = model.FileType
		recordView.Duration = model.Duration
		recordView.CreateBy = model.CreateBy // 添加这而，需要记录是被谁创建的
		recordView.FileTime = model.FileTime
		recordView.CreateTime = now
		recordView.UpdateTime = now
		recordView.Sort = int(index) + k + 1
		recordView.OperatorType = model.OperatorType
		recordView.IsConfirm = 1
		*models = append(*models, recordView)
	}

}

func (s *RecordListViewInsertReq) GetId() interface{} {
	return s.Id
}

type RecordListViewUpdateReq struct {
	Id           int    `uri:"id" comment:"" validate:"required"` //
	FileName     string `json:"file_name" comment:"文件名"  validate:"required"`
	LogoUrl      string `json:"logo_url" comment:"封面图地址"  validate:"required"`
	Introduction string `json:"introduction" comment:"简介"`
	common.ModelTime
	common.ControlBy
}

func (s *RecordListViewUpdateReq) Generate(model *live.RecordListView) {
	model.FileName = s.FileName
	model.LogoUrl = s.LogoUrl
	model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
	model.UpdateTime = time.Now().Unix()
	model.Introduction = s.Introduction
}

func (s *RecordListViewUpdateReq) GetId() interface{} {
	return s.Id
}

// RecordListViewGetReq 功能获取请求参数
type RecordListViewGetReq struct {
	Id int `uri:"id"`
}

func (s *RecordListViewGetReq) GetId() interface{} {
	return s.Id
}

// RecordListViewDeleteReq 功能删除请求参数
type RecordListViewDeleteReq struct {
	Ids []int `json:"ids"`
}

func (s *RecordListViewDeleteReq) GetId() interface{} {
	return s.Ids
}

type SyncRecordReq struct {
	TenantId  string `json:"tenant_id" comment:"租户" validate:"required"`
	BasicId   int    `json:"basic_id" comment:"基本信息id"  validate:"required"`
	IsConfirm int    `json:"is_confirm" comment:"是否直接生成回看视频 1是"`
	common.ControlBy
}

type GetNeedToAddRecordsReq struct {
	dto.Pagination `search:"-"`
	BasicId        int    `json:"basic_id"  search:"type:exact;column:basic_id;table:record_list" validate:"required"`
	TenantId       string `json:"tenant_id"  search:"type:exact;column:tenant_id;table:record_list" validate:"required"`
	FileTime       string `json:"file_time"  search:"type:order desc;column:file_time;table:record_list"`
}

func (m *GetNeedToAddRecordsReq) GetAddRecordNeedSearch() interface{} {
	return *m
}

type RecordUpOrDownReq struct {
	Id   int `json:"id" comment:"" validate:"required"` //
	Type int `json:"type" comment:"移动类型 1 上移 2下移"  validate:"required,gt=0"`
	common.ControlBy
}
